package com.zhi.service.impl;

import com.zhi.dao.GradeRepository;
import com.zhi.entity.Grade;
import com.zhi.service.GradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class GradeServiceImpl implements GradeService {
	
	@Autowired
	private GradeRepository gradeRepository;

	@Override
	public List<Grade> getEntityList() {
		return gradeRepository.findAll();
	}
	
	@Override
	public List<Object[]> getEntityListWithCodeName() {
		return gradeRepository.getEntityListWithCodeName();
	}
	

	@Override
	public Page<Grade> getEntityListWithCodeName(Pageable pageable) {
		return gradeRepository.getEntityListWithCodeName(pageable);
	}

	@Override
	public Grade getOne(String gradeId) {
		return gradeRepository.getOne(gradeId);
	}
	
	@Override
	public List<Grade> findAll(Grade grade) {
		Example<Grade> example =Example.of(grade);
		return gradeRepository.findAll(example);
	}

	@Override
	public List<Grade> findAllById(List<String> ids){
		return gradeRepository.findAllById(ids);
	}

	@Override
	public void save(Grade Grade) {
		gradeRepository.save(Grade);
	}

	@Override
	public void edit(Grade Grade) {
		gradeRepository.save(Grade);
		
	}

	@Override
	public void delete(String gradeId) {
		gradeRepository.deleteById(gradeId);
	}

	@Override
	public Integer count(Grade Grade) {
		Example<Grade> example =Example.of(Grade);
		return (int) gradeRepository.count(example);
	}


}
